<!-- saved from url=(0014)about:internet -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>XMLNode.as</title>
<link rel="stylesheet" type="text/css" href="../../../../SourceStyles.css"/>
</head>

<body><pre><span class="ActionScriptpackage">package</span> <span class="ActionScriptDefault_Text">net</span>.<span class="ActionScriptDefault_Text">manaca</span>.<span class="ActionScriptDefault_Text">xml</span>
<span class="ActionScriptBracket/Brace">{</span>
    <span class="ActionScriptReserved">public</span> <span class="ActionScriptclass">class</span> <span class="ActionScriptDefault_Text">XMLNode</span> <span class="ActionScriptReserved">extends</span> <span class="ActionScriptDefault_Text">Object</span>
    <span class="ActionScriptBracket/Brace">{</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptReserved">static</span> <span class="ActionScriptReserved">const</span> <span class="ActionScriptDefault_Text">ATTRIBUTE</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span>            <span class="ActionScriptOperator">=</span> 0;
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptReserved">static</span> <span class="ActionScriptReserved">const</span> <span class="ActionScriptDefault_Text">ELEMENT</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span>               <span class="ActionScriptOperator">=</span> 1;
        
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">domNode</span><span class="ActionScriptOperator">:*</span>;
    
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">XMLNode</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">node</span><span class="ActionScriptOperator">:*</span><span class="ActionScriptBracket/Brace">)</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">this</span>.<span class="ActionScriptDefault_Text">domNode</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">node</span>;
        <span class="ActionScriptBracket/Brace">}</span>
    
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptReserved">get</span> <span class="ActionScriptDefault_Text">node</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">:*</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">return</span> <span class="ActionScriptDefault_Text">domNode</span>;
        <span class="ActionScriptBracket/Brace">}</span>
    
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">getChildCount</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">type</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span>, <span class="ActionScriptDefault_Text">namespaceURI</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>, <span class="ActionScriptDefault_Text">name</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">QName</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">QName</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">namespaceURI</span>, <span class="ActionScriptDefault_Text">name</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptReserved">if</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">domNode</span> <span class="ActionScriptReserved">is</span> <span class="ActionScriptDefault_Text">XML</span><span class="ActionScriptBracket/Brace">)</span>
            <span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptReserved">switch</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">type</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptBracket/Brace">{</span>
                    <span class="ActionScriptReserved">case</span> <span class="ActionScriptDefault_Text">ATTRIBUTE</span><span class="ActionScriptOperator">:</span>
                        <span class="ActionScriptReserved">return</span> <span class="ActionScriptDefault_Text">domNode</span>.<span class="ActionScriptDefault_Text">attribute</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptBracket/Brace">)</span>.<span class="ActionScriptDefault_Text">length</span><span class="ActionScriptBracket/Brace">()</span>;
                    <span class="ActionScriptReserved">break</span>;
                    <span class="ActionScriptReserved">case</span> <span class="ActionScriptDefault_Text">ELEMENT</span><span class="ActionScriptOperator">:</span>
                        <span class="ActionScriptReserved">return</span> <span class="ActionScriptDefault_Text">domNode</span>.<span class="ActionScriptDefault_Text">child</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptBracket/Brace">)</span>.<span class="ActionScriptDefault_Text">length</span><span class="ActionScriptBracket/Brace">()</span>;
                    <span class="ActionScriptReserved">break</span>;
                <span class="ActionScriptBracket/Brace">}</span>
            <span class="ActionScriptBracket/Brace">}</span>
            <span class="ActionScriptReserved">return</span> 0;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">getChildAt</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">type</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span>, <span class="ActionScriptDefault_Text">namespaceURI</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>, <span class="ActionScriptDefault_Text">name</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>, <span class="ActionScriptDefault_Text">index</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">XML</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">QName</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">QName</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">namespaceURI</span>, <span class="ActionScriptDefault_Text">name</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptReserved">if</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">domNode</span> <span class="ActionScriptReserved">is</span> <span class="ActionScriptDefault_Text">XML</span><span class="ActionScriptBracket/Brace">)</span>
            <span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptReserved">switch</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">type</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptBracket/Brace">{</span>
                    <span class="ActionScriptReserved">case</span> <span class="ActionScriptDefault_Text">ATTRIBUTE</span><span class="ActionScriptOperator">:</span>
                        <span class="ActionScriptReserved">return</span> <span class="ActionScriptDefault_Text">domNode</span>.<span class="ActionScriptDefault_Text">attribute</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptBracket/Brace">)[</span><span class="ActionScriptDefault_Text">index</span><span class="ActionScriptBracket/Brace">]</span>;
                    <span class="ActionScriptReserved">break</span>;
                    <span class="ActionScriptReserved">case</span> <span class="ActionScriptDefault_Text">ELEMENT</span><span class="ActionScriptOperator">:</span>
                        <span class="ActionScriptReserved">return</span> <span class="ActionScriptDefault_Text">domNode</span>.<span class="ActionScriptDefault_Text">child</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptBracket/Brace">)[</span><span class="ActionScriptDefault_Text">index</span><span class="ActionScriptBracket/Brace">]</span>;
                    <span class="ActionScriptReserved">break</span>;
                <span class="ActionScriptBracket/Brace">}</span>
            <span class="ActionScriptBracket/Brace">}</span>
            <span class="ActionScriptReserved">return</span> <span class="ActionScriptReserved">null</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">setChildAt</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">type</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span>, <span class="ActionScriptDefault_Text">namespaceURI</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>, <span class="ActionScriptDefault_Text">name</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>, <span class="ActionScriptDefault_Text">index</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span>, <span class="ActionScriptDefault_Text">value</span><span class="ActionScriptOperator">:*</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">QName</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">QName</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">namespaceURI</span>, <span class="ActionScriptDefault_Text">name</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptReserved">if</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">domNode</span> <span class="ActionScriptReserved">is</span> <span class="ActionScriptDefault_Text">XML</span><span class="ActionScriptBracket/Brace">)</span>
            <span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptReserved">switch</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">type</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptBracket/Brace">{</span>
                    <span class="ActionScriptReserved">case</span> <span class="ActionScriptDefault_Text">ATTRIBUTE</span><span class="ActionScriptOperator">:</span>
                        <span class="ActionScriptDefault_Text">domNode</span>.<span class="ActionScriptDefault_Text">attribute</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptBracket/Brace">)[</span><span class="ActionScriptDefault_Text">index</span><span class="ActionScriptBracket/Brace">]</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">value</span> <span class="ActionScriptOperator">==</span> <span class="ActionScriptReserved">null</span><span class="ActionScriptBracket/Brace">)</span> <span class="ActionScriptOperator">?</span> <span class="ActionScriptReserved">null</span> <span class="ActionScriptOperator">:</span> <span class="ActionScriptDefault_Text">value</span>.<span class="ActionScriptDefault_Text">toString</span><span class="ActionScriptBracket/Brace">()</span>;
                    <span class="ActionScriptReserved">break</span>;
                    <span class="ActionScriptReserved">case</span> <span class="ActionScriptDefault_Text">ELEMENT</span><span class="ActionScriptOperator">:</span>
                        <span class="ActionScriptReserved">if</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">value</span> <span class="ActionScriptReserved">is</span> <span class="ActionScriptDefault_Text">XML</span><span class="ActionScriptBracket/Brace">)</span>
                        <span class="ActionScriptBracket/Brace">{</span>
                            <span class="ActionScriptDefault_Text">domNode</span>.<span class="ActionScriptDefault_Text">child</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptBracket/Brace">)[</span><span class="ActionScriptDefault_Text">index</span><span class="ActionScriptBracket/Brace">]</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">&apos;&apos;</span>;
                            <span class="ActionScriptDefault_Text">domNode</span>.<span class="ActionScriptDefault_Text">child</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptBracket/Brace">)[</span><span class="ActionScriptDefault_Text">index</span><span class="ActionScriptBracket/Brace">]</span>.<span class="ActionScriptDefault_Text">normalize</span><span class="ActionScriptBracket/Brace">()</span>;
                            <span class="ActionScriptDefault_Text">domNode</span>.<span class="ActionScriptDefault_Text">child</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptBracket/Brace">)[</span><span class="ActionScriptDefault_Text">index</span><span class="ActionScriptBracket/Brace">]</span>.<span class="ActionScriptDefault_Text">appendChild</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">value</span><span class="ActionScriptBracket/Brace">)</span>;
                        <span class="ActionScriptBracket/Brace">}</span>
                        <span class="ActionScriptReserved">else</span>
                        <span class="ActionScriptBracket/Brace">{</span>
                            <span class="ActionScriptDefault_Text">domNode</span>.<span class="ActionScriptDefault_Text">child</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptBracket/Brace">)[</span><span class="ActionScriptDefault_Text">index</span><span class="ActionScriptBracket/Brace">]</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">value</span> <span class="ActionScriptOperator">==</span> <span class="ActionScriptReserved">null</span><span class="ActionScriptBracket/Brace">)</span> <span class="ActionScriptOperator">?</span> <span class="ActionScriptReserved">null</span> <span class="ActionScriptOperator">:</span> <span class="ActionScriptDefault_Text">value</span>.<span class="ActionScriptDefault_Text">toString</span><span class="ActionScriptBracket/Brace">()</span>;
                        <span class="ActionScriptBracket/Brace">}</span>
                    <span class="ActionScriptReserved">break</span>;
                <span class="ActionScriptBracket/Brace">}</span>
            <span class="ActionScriptBracket/Brace">}</span>
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">addChild</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">type</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span>, <span class="ActionScriptDefault_Text">namespaceURI</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>, <span class="ActionScriptDefault_Text">name</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>, <span class="ActionScriptDefault_Text">value</span><span class="ActionScriptOperator">:*</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">QName</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">QName</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">namespaceURI</span>, <span class="ActionScriptDefault_Text">name</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptReserved">if</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">domNode</span> <span class="ActionScriptReserved">is</span> <span class="ActionScriptDefault_Text">XML</span><span class="ActionScriptBracket/Brace">)</span>
            <span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptReserved">switch</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">type</span><span class="ActionScriptBracket/Brace">)</span>
                <span class="ActionScriptBracket/Brace">{</span>
                    <span class="ActionScriptReserved">case</span> <span class="ActionScriptDefault_Text">ELEMENT</span><span class="ActionScriptOperator">:</span>
                        <span class="ActionScriptDefault_Text">domNode</span>.<span class="ActionScriptDefault_Text">appendChild</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">value</span><span class="ActionScriptBracket/Brace">)</span>;
                    <span class="ActionScriptReserved">break</span>;
                <span class="ActionScriptBracket/Brace">}</span>
            <span class="ActionScriptBracket/Brace">}</span>
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">removeChild</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">type</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span>, <span class="ActionScriptDefault_Text">namespaceURI</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>, <span class="ActionScriptDefault_Text">name</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>, <span class="ActionScriptDefault_Text">index</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">QName</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">QName</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">namespaceURI</span>, <span class="ActionScriptDefault_Text">name</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptReserved">switch</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">type</span><span class="ActionScriptBracket/Brace">)</span>
            <span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptReserved">case</span> <span class="ActionScriptDefault_Text">ELEMENT</span><span class="ActionScriptOperator">:</span>
                    <span class="ActionScriptReserved">delete</span> <span class="ActionScriptDefault_Text">domNode</span>.<span class="ActionScriptDefault_Text">child</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptBracket/Brace">)[</span><span class="ActionScriptDefault_Text">index</span><span class="ActionScriptBracket/Brace">]</span>;
                <span class="ActionScriptReserved">break</span>;
                <span class="ActionScriptReserved">case</span> <span class="ActionScriptDefault_Text">ATTRIBUTE</span><span class="ActionScriptOperator">:</span>
                    <span class="ActionScriptDefault_Text">domNode</span>.<span class="ActionScriptDefault_Text">attribute</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">qName</span><span class="ActionScriptBracket/Brace">)[</span>0<span class="ActionScriptBracket/Brace">]</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">null</span>;
                <span class="ActionScriptReserved">break</span>;
            <span class="ActionScriptBracket/Brace">}</span>
        <span class="ActionScriptBracket/Brace">}</span>
    <span class="ActionScriptBracket/Brace">}</span>
<span class="ActionScriptBracket/Brace">}</span></pre></body>
</html>
